#pragma once

#include"pgVec3.h"

class PALEGEM_API pgMat44
{
public:

	pgMat44();
	pgMat44(float f11, float f12, float f13, float f14,
		float f21, float f22, float f23, float f24,
		float f31, float f32, float f33, float f34,
		float f41, float f42, float f43, float f44);
	pgMat44(const XMMATRIX &m);

	operator XMMATRIX ()
	{
		return XMMatrixSet(val[0][0], val[0][1], val[0][2], val[0][3],
						val[1][0], val[1][1], val[1][2], val[1][3],
						val[2][0], val[2][1], val[2][2], val[2][3],
						val[3][0], val[3][1], val[3][2], val[3][3]);
	}

	pgMat44 operator * (const pgMat44 &m);
	
	void operator *= (const pgMat44 &m)
	{
		//this = this * m;
	}

	pgVec3 GetRightAxis();
	pgVec3 GetUpAxis();
	pgVec3 GetFwdAxis();
	pgVec3 GetTranslation();

	static pgMat44 Identity()
	{
		return pgMat44(1, 0, 0, 0,
						0, 1, 0, 0,
						0, 0, 1, 0,
						0, 0, 0, 1);
	}

	static pgMat44 BuildTranslationMatrix( float x, float y,  float z)
	{
		return pgMat44(1.0f, 0.0f, 0.0f, 0.0f,
						0.0f, 1.0f, 0.0f, 0.0f,
						0.0f, 0.0f, 1.0f, 0.0f,
						x, y, z, 1.0f);
	}

	static pgMat44 BuildTranslationMatrix(pgVec3 &vec)
	{
		return BuildTranslationMatrix(vec.GetX(), vec.GetY(), vec.GetZ());
	}

	static pgMat44 BuildRotationX(float fAngle)
	{
		float cos = cosf(fAngle);
		float sin = sinf(fAngle);

		return pgMat44(1.0f, 0.0f, 0.0f, 0.0f,
						0.0f, cos, sin, 0.0f,
						0.0f, -sin, cos, 0.0f,
						0.0f, 0.0f, 0.0f, 1.0f);
						
	}

	static pgMat44 BuildRotationY(float fAngle)
	{
		float cos = cosf(fAngle);
		float sin = sinf(fAngle);

		return pgMat44(cos, 0.0f, -sin, 0.0f,
						0.0f, 1.0f, 0.0f, 0.0f,
						sin, 0.0f, cos, 0.0f,
						0.0f, 0.0f, 0.0f, 1.0f);
	}

	static pgMat44 BuildRotationZ(float fAngle)
	{
		float cos = cosf(fAngle);
		float sin = sinf(fAngle);

		return pgMat44(cos, sin, 0.0f, 0.0f,
						-sin, cos, 0.0f, 0.0f,
						0.0f, 0.0f, 1.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 1.0f);
	}
	

private:

	float val[4][4];
};